import {
  getWorkDetail
} from '../../../api/index';
Page({
  data: {
    list: [],
    favor: true,
    worklist: [],
    baseUrl: 'https://oss.peibanmao.com/',
    filterId: null,

  },
  init() {},

  onShow() {
    this.getTabBar()
  },
  onChange() {},
  onLoad(options) {
    this.init(true);
    console.log(options, 'options')
    this.setData({
      filterId: options.id
    })
    this.getWorkDetailFn()
  },
  onFavor() {
    this.setData({
      favor: !this.data.favor,
    });
  },
  getWorkDetailFn() {
    this.setData({
      isLoading: true,
    });
    getWorkDetail({
      id: Number(this.data.filterId),
    }).then(res => {
      const newData = this.data.worklist.concat(res.data.item);
      console.log(newData, 'newDatanewData')
      //const hasMore = res.hasMore;
      this.setData({
        worklist: newData,
      });
    })
  },
  goToPage() {
    wx.switchTab({
      url: '/pages/cart/index',
    })
  },

  //转发给朋友
  onShareAppMessage() {
    const promise = new Promise(resolve => {
      setTimeout(() => {
        resolve({
          title: '时忆旅拍'
        })
      }, 2000)
    })
    return {
      title: '时忆旅拍',
      path: '/pages/goods/itemWork/index?id=' + this.data.filterId,
      promise
    }
  },
  //分享到朋友圈
  onShareTimeline() {},
});